package com.tsunami.auth.config;

import com.tsunami.auth.service.auth.IOptLogService;
import com.tsunami.log.entity.OptLogDTO;
import com.tsunami.log.event.SysLogListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

import java.util.function.Consumer;

/**
 * @Classname SysLogConfiguration
 * @Description TODO
 * @Date 2021-11-16 16:59
 * @Created by lx
 */
@Configuration
@EnableAsync
public class SysLogConfiguration {
    @Bean
    public SysLogListener sysLogListener(IOptLogService optLogService){
        Consumer<OptLogDTO> consumer =(optLogDTO -> optLogService.save(optLogDTO));
        return new SysLogListener(consumer);
    }
}
